library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✔ ggplot2 3.3.6 ✔ purrr 0.3.4
## ✔ tibble 3.1.7 ✔ dplyr 1.0.9
## ✔ tidyr 1.2.0 ✔ stringr 1.4.0
## ✔ readr 2.1.2 ✔ forcats 0.5.1
## Warning: package 'ggplot2' was built under R version 4.2.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(sf)
## Linking to GEOS 3.9.1, GDAL 3.3.2, PROJ 7.2.1; sf_use_s2() is TRUE
library(tidycensus)
## Warning: package 'tidycensus' was built under R version 4.2.1
library(tmap)
places <- st_read("Data/GA_MSA_pts.gpkg")
## Reading layer `GA_MSA_pts' from data source
## `C:\Users\pball24\My Drive\Patrick Academic\PDRA\Projects\CARTO SDSC 2022\CARTO-SDSC2022\Data\GA_MSA_pts.gpkg'
## using driver `GPKG'
## Simple feature collection with 74345 features and 5 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -85.3491 ymin: 32.84559 xmax: -83.28591 ymax: 34.56562
## Geodetic CRS: WGS 84
Look at the attributes:
glimpse(places)
## Rows: 74,345
## Columns: 6
## $ top_category <chr> "Accounting, Tax Preparation, Bookkeeping, and Payroll S…
## $ sub_category <chr> "Other Accounting Services", "Other Accounting Services"…
## $ brands <chr> "", "", "", "", "", "", "", "", "", "", "", "", "", "", …
## $ location_name <chr> "Bookkeeping by Andrea", "Pereira and Company CPA", "Bra…
## $ MSA <chr> "Atlanta-Sandy Springs-Alpharetta, GA", "Atlanta-Sandy S…
## $ geom <POINT [°]> POINT (-84.26228 34.12522), POINT (-84.50167 33.94…
Let’s take a look at the distribution of grocery stores:
grocery <- places %>%
filter(top_category == "Grocery Stores") %>%
mutate(brands = case_when(brands == "" ~ "Unclassified",
TRUE ~ brands))
tmap_mode("view")
## tmap mode set to interactive viewing
tm_shape(grocery) +
tm_dots(col = "brands", size = 0.05)
geodemo <- st_read("Data/GA_GD.gpkg")
## Reading layer `GA_GD' from data source
## `C:\Users\pball24\My Drive\Patrick Academic\PDRA\Projects\CARTO SDSC 2022\CARTO-SDSC2022\Data\GA_GD.gpkg'
## using driver `GPKG'
## Simple feature collection with 1021 features and 3 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -85.38658 ymin: 32.84464 xmax: -83.2692 ymax: 34.61792
## Geodetic CRS: WGS 84
glimpse(geodemo)
## Rows: 1,021
## Columns: 4
## $ GEOID <chr> "01029959500", "01029959800", "01111000200", "01111000400",…
## $ TractGroup <chr> "C: Middle Income, Single Family Homes", "C: Middle Income,…
## $ MSA <chr> "Atlanta-Sandy Springs-Alpharetta, GA", "Atlanta-Sandy Spri…
## $ geom <MULTIPOLYGON [°]> MULTIPOLYGON (((-85.3863 33..., MULTIPOLYGON (…
tm_shape(geodemo) +
tm_fill(col = "TractGroup", alpha = 0.5) +
tm_borders(col = "black", lwd = 0.5)